#ifndef CIPODCONFIG_H_
#define CIPODCONFIG_H_

#include <list>
#include <string>
#include "CIpodLib.h"

#ifdef __cplusplus
extern "C"{
#endif

class IPODProtocol {
public:
    enum { ALL, IAP1, IAP2 };
};

class IPODPower {
public:
    enum { NONE, RESERVED, ADVANCED };
};

class IPODEAMatchAction {
public:
    enum { NO_ACTION, OPTIONAL_ACTION, NO_ALERT, NO_COMM_PROTOCOL };
};

class IPODSampleRate {
public:
    enum { RATE_8000HZ, RATE_11025HZ, RATE_12000HZ, RATE_16000HZ, RATE_22050HZ, RATE_24000HZ, RATE_32000HZ, RATE_44100HZ, RATE_48000HZ };
};

class IPODEngine {
public:
    enum { GASOLINE, DIESEL, ELECTRIC, CNG };
};

class IPODHIDFunction {
public:
    enum { KEYBOARD, MEDIA, TOUCH, RESERVED, GAMEPAD_FORM_FITTING, GAMEPAD_NONFORM_FITTING, CONTROL, HEADSET };
};

typedef union {
    uint32 value;

    struct {
        uint8 app               : 1;
        uint8 touch             : 1;
        uint8 bluetooth         : 1;
        uint8 communications    : 1;
        uint8 authentication    : 1;
        uint8 notifications     : 1;
        uint8 eap               : 1;
        uint8 hid               : 1;
        uint8 location          : 1;
        uint8 media             : 1;
        uint8 playing           : 1;
        uint8 power             : 1;
        uint8 audio             : 1;
        uint8 vehicle           : 1;
        uint8 voiceover         : 1;
        uint8 wifi              : 1;
        uint8 serialnumber      : 1;
        uint8 oob               : 1;
    };
} IPODMessage;

typedef struct {
    uint8                       id;
    std::string                 name;
    int                         action;
    uint16                      nativeid;
    bool                        carplay;
} ExternalAccessoryProtocol;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        connection;
} SerialTransportComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        connection;
    std::list<int>              rates;
} USBDeviceTransportComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        connection;
    uint8                       number;
    bool                        carplay;
} USBHostTransportComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        connection;
} BluetoothTransportComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    int                         function;
} USBDeviceHIDComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    std::list<int>              engines;
    std::string                 display;
} VehicleInformationComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        range;
    bool                        temperature;
    bool                        warning;
} VehicleStatusComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        GPGGA;
    bool                        GPRMC;
    bool                        GPGSV;
    bool                        PASCD;
    bool                        PAGCD;
    bool                        PAACD;
    bool                        GPHDT;
} LocationInformationComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    int                         function;
    uint16                      transportid;
    uint16                      number;
} USBHostHIDComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    bool                        connection;
    bool                        carplay;
} WirelessCarPlayTransportComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    int                         function;
    uint16                      transportid;
} BluetoothHIDComponent;

typedef struct {
    uint16                      id;
    std::string                 name;
    uint16                      maxCurRoadNameLen;
    uint16                      maxDestNameLen;
    uint16                      maxAManeRoadNameLen;
    uint16                      maxManeDesLen;
    uint16                      maxGuiManeStoCap;
    uint16                      maxLaneGuiDesLen;
    uint16                      maxLaneGuiStoCap;
} RouteGuidanceDisplayComponent;

typedef struct {
    std::string                                     name;
    std::string                                     modelIdentifier;
    std::string                                     manufacturer;
    std::string                                     serialNumber;
    std::string                                     firmwareVersion;
    std::string                                     hardwareVersion;
    IPODMessage                                     messages;
    int                                             power;
    uint16                                          maxCurrDrawn;
    ExternalAccessoryProtocol                       eaprotocol;
    std::string                                     appTeamId;
    std::string                                     currentLanguage;
    std::list<std::string>                          supportedLanguages;
    SerialTransportComponent                        serialTransport;
    USBDeviceTransportComponent                     usbDeviceTransport;
    USBHostTransportComponent                       usbHostTransport;
    BluetoothTransportComponent                     bluetoothTransport;
    std::list<USBDeviceHIDComponent>                usbDeviceHIDs;
    VehicleInformationComponent                     vehicleInfo;
    VehicleStatusComponent                          vehicleStatus;
    LocationInformationComponent                    locationInfo;
    std::list<USBHostHIDComponent>                  usbHostHIDs;
    std::list<WirelessCarPlayTransportComponent>    wirelessCarPlayTransports;
    BluetoothHIDComponent                           bluetoothHID;
    RouteGuidanceDisplayComponent                   routeGuidance;
    std::string                                     productPlanUID;
} IPODIdentification;

class CIpodConfig {
public:
    static int init(int mode, const char *cfgPath, int connMode,int hidg);
    static int deinit();
    static int getMode();
    static int getHidg();
    static int connMode();
    static int getProtocol();

    static IPODIdentification *getIdentification();

private:
    static int                      s_Mode;
    static int                      s_ConnMode;
    static int                      s_Protocol;
    static IPODIdentification       s_Identification;
    static int                      s_hidg;

    static void debugConfig();
};

#ifdef __cplusplus
}
#endif

#endif /* CIPODCONFIG_H_ */
